# coding=utf-8
from iHome import create_app, db, models
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand

# # 创建配置类
# class Config(object):
#     DEBUG = True
#     # 数据库的配置
#     # SQLAlCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/iHome"
#     SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/iHome"
#     SQLALCHEMY_TRACK_MODIFICATIONS = False
#     # redis的配置
#     REDIS_HOST = '127.0.0.1'
#     REDIS_PORT = 6379
#     SECRET_KEY = 'dycnXaNu9Low2BH79WyJ2unHX6Ml65rQI8i/g9ibAJNi6WAtNjTIKFU+UEJu6vUr'
#     # 设置session配置
#     SESSION_TYPE = 'redis'
#     SESSION_REDIS = redis.StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
#     SESSION_USE_SIGNER = True  # 让 cookie 中的 session_id 被加密签名处理
#     PERMANENT_SESSION_LIFETIME = 7200


# 加载配置
# app.config.from_object(Config)
# # 创建数据库对象
# db = SQLAlchemy(app)
# # 链接redis数据库并创建一个对象
# redis_store = redis.StrictRedis(host=Config.REDIS_HOST, port=Config.REDIS_PORT)
# # 开启csrf保护
# CSRFProtect(app)
# # 存储session
# Session(app)
app = create_app('development')
# 创建脚本运行对象
manger = Manager(app)
Migrate(app, db)
# 添加数据库迁移命令加入脚本
manger.add_command('db', MigrateCommand)

if __name__ == '__main__':
    # print app.url_map
    manger.run()
